1 Public Class FrmDEFFECTIVE_STOCKS_DATA_ADD
2
3     Private Sub FrmDEFFECTIVE_STOCKS_DATA_ADD_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
4         Me.Text =
"Defect Details"
5     End Sub
6
7     Private Sub FrmDEFFECTIVE_STOCKS_DATA_ADD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
8         If Split(Me.Text,
" - ")(1) <> "Edit" Then
9             FrmDEFFECTIVE_STOCKS_LIST.ShowDialog()
10             txtdefqty.Select()
11             txtdefqty.Text =
"0"
12         Else
13             sqlSTR =
"SELECT *, *, *, * " & _
14               
"FROM ((((TBL_Suppliers " & _
15               
"INNER JOIN TBL_Purchase_Order ON TBL_Suppliers.Supp_ID = TBL_Purchase_Order.Supp_ID) " & _
16               
"INNER JOIN TBL_Deffective_PO_Details ON TBL_Purchase_Order.Purchase_ID = TBL_Deffective_PO_Details.Purchase_ID) " & _
17               
"INNER JOIN TBL_Purchase_Detail ON TBL_Deffective_PO_Details.Purchase_ID = TBL_Purchase_Detail.Purchase_ID) " & _
18               
"INNER JOIN TBL_Category_Item_File ON TBL_Deffective_PO_Details.Item_ID = TBL_Category_Item_File.Item_ID) " & _
19               
"WHERE TBL_Deffective_PO_Details.Purchase_ID =" & Split(globalID, "x")(1) & _
20               
" AND TBL_Deffective_PO_Details.Purchase_Detail_ID =" & Split(globalID, "x")(0)
21             ExecuteSQLQuery(sqlSTR)
22             
' txtid.Text = sqlDT.Rows(0)("TBL_Deffective_PO_Details.Item_ID")
23             
' txtdtl.Text = sqlDT.Rows(0)("TBL_Deffective_PO_Details.Purchase_Detail_ID")
24             
' txtname.Text = sqlDT.Rows(0)("Item_Name")
25             
' txtdesc.Text = sqlDT.Rows(0)("Item_Description")
26             
' txtprice.Text = sqlDT.Rows(0)("TBL_Purchase_Detail.Item_Price")
27             If sqlDT.Rows.Count >
0 Then
28                 txtbarcode.Text = sqlDT.Rows(
0)("Item_Barcode")
29             End If
30
31             
' txtunit.Text = sqlDT.Rows(0)("Unit")
32             
' txtqty.Text = sqlDT.Rows(0)("Item_QTY")
33             
' txtdefqty.Text = sqlDT.Rows(0)("Def_QTY")
34         End If
35     End Sub
36
37     Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
38         Me.Close()
39     End Sub
40
41     Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
42         Dim i As Integer
43         With FrmDEFFECTIVE_STOCKS_ADD
44             If txtdefqty.Text =
"0" Then
45                 MsgBox(
"Def.Qty should not be zero !!", MsgBoxStyle.Information, "Sales and Inventory")
46                 txtdefqty.Select()
47                 Exit Sub
48             End If
49
50             If CDbl(txtdefqty.Text) > CDbl(txtqty.Text) Then
51                 MsgBox(
"Def.Qty should not be greater than to Current Quantity !! ", MsgBoxStyle.Information, "Sales and Inventory")
52                 txtdefqty.Select()
53                 Exit Sub
54             End If
55
56             If Split(Me.Text,
" - ")(1) = "Add" Then
57                 For i =
0 To .lstitems.Items.Count - 1
58                     If .lstitems.Items(i).Text = txtid.Text Then
59                         MsgBox(
"Current details is already on the defective list !!", MsgBoxStyle.Information, "Sales and Inventory")
60                         Exit Sub
61                     End If
62                 Next
63
64                 .lstitems.Items.Add(txtid.Text)
65                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtdtl.Text)
66                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtname.Text)
67                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtdesc.Text)
68                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtprice.Text)
69                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtqty.Text)
70                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtdefqty.Text)
71                 .lstitems.Items(.lstitems.Items.Count -
1).SubItems.Add(txtunit.Text)
72                 .cmdSave.Enabled = True
73                 .cmdEdit.Enabled = True
74             Else
75                 For i =
0 To .lstitems.Items.Count - 1
76                     If .lstitems.Items(i).Text = txtid.Text Then
77                         .lstitems.Items(i).SubItems(
6).Text = txtdefqty.Text
78                     End If
79                 Next
80                 .cmdSave.Enabled = True
81                 .cmdEdit.Enabled = True
82             End If
83         End With
84         Me.Close()
85         
' With FrmDEFFECTIVE_STOCKS_DATA_ADD
86         
' .txtid.Text = Me.lstitems.FocusedItem.Text
87         
' .txtdtl.Text = Me.lstitems.FocusedItem.SubItems(1).Text
88         
' .txtname.Text = Me.lstitems.FocusedItem.SubItems(2).Text
89         
' .txtdesc.Text = Me.lstitems.FocusedItem.SubItems(3).Text
90         
' .txtprice.Text = Me.lstitems.FocusedItem.SubItems(4).Text
91         
' .txtbarcode.Text = Me.lstitems.FocusedItem.SubItems(5).Text
92         
' .txtqty.Text = Me.lstitems.FocusedItem.SubItems(6).Text
93         
' .txtunit.Text = Me.lstitems.FocusedItem.SubItems(7).Text
94         
' End With
95     End Sub
96
97     Private Sub txtdefqty_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtdefqty.TextChanged
98         txtdefqty.Text = str_Filter(txtdefqty,
48, 57, 0, 0)
99         If txtdefqty.Text =
"" Then txtdefqty.Text = "0"
100     End Sub
101 End Class


Gõ tìm kiếm nhanh...